﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Photocopy.Model;
using Photocopy.Business;

namespace Photocopy
{
    public partial class RebuildTemplate : System.Web.UI.MasterPage
    {
        ProductData pd = new ProductData();
        protected void Page_Load(object sender, EventArgs e)
        {
            RptBestProduct.DataSource = pd.getHotProduct();
            RptBestProduct.DataBind();
            lbLuotTruyCap.Text = Application["SoLuotTruyCap"].ToString();
            lbNguoiOnl.Text = Application["SoNguoiOnl"].ToString();
        }

        protected void RptBestProduct_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "GetProductDetail")
            {
                Label lblsanpham = (Label)e.Item.FindControl("lbSpID");
                int SanphamID = Int32.Parse(lblsanpham.Text);
                if (pd.CheckSale(SanphamID) == true)
                {
                    Session["sanpham"] = pd.getProductSale(SanphamID);
                    Response.Redirect("ProductDetails.aspx");
                }
                else
                {
                    Session["sanpham"] = pd.getProduct(SanphamID);
                    Response.Redirect("ProductDetails.aspx");
                }
            }
        }


    }
}